package view.bean;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.nav.RichCommandButton;

import org.apache.myfaces.trinidad.component.UIXIterator;

public class PaginationBean {
    private UIXIterator paginationIterator;
    private RichCommandButton previousButton;

    public PaginationBean() {
    }

    public void setPaginationIterator(UIXIterator paginationIterator) {
        this.paginationIterator = paginationIterator;
    }

    public UIXIterator getPaginationIterator() {
        return paginationIterator;
    }

    public void nextSetOfRows(ActionEvent actionEvent) {
        getPaginationIterator().setFirst(getPaginationIterator().getFirst()+10);
        if((getPaginationIterator().getFirst()-10)> 0) {
            getPreviousButton().setDisabled(false);
        }

        // Add event code here...
    }

    public void previousSetOfRows(ActionEvent actionEvent) {
            getPreviousButton().setDisabled(false);
        if((getPaginationIterator().getFirst()-10)< 0) {
            getPreviousButton().setDisabled(true);
        }
        else{
           getPaginationIterator().setFirst(getPaginationIterator().getFirst()-10); 
        }
        
        }
        

    public void setPreviousButton(RichCommandButton previousButton) {
        this.previousButton = previousButton;
    }

    public RichCommandButton getPreviousButton() {
        return previousButton;
    }
}
